import { createPinia } from 'pinia'
import { createPersistedState } from 'pinia-plugin-persistedstate'
import { lStorage } from '@/utils/storage'

const pinia = createPinia()
// 将插件添加到 pinia 实例上，全局配置持久化的storage
pinia.use(
	createPersistedState({
		storage: {
			getItem: (key: string) => {
				return lStorage.get(key)
			},
			setItem: (key: string, value: string): void => {
				lStorage.set(key, value)
			},
		},
	})
)

export default pinia
